// pages/address/index.js
import tips from '../../../../class/Utils/Tips'
import http from '../../../../service/http.js'


Page({
  data: {
    addrlist: []
  },
  onLoad: function (options) {
    var that = this;
    var tjorder = options.tjorder ? options.tjorder : 0
    that.setData({
      tjorder: tjorder
    })
    this.setData({
      lj: options.lj ? options.lj : 0
    })
  },
  setdft: function (e) {
    var that = this;
    let id = e.currentTarget.dataset.id;

    var uid = wx.getStorageSync('user').userid;
    http.req('/Wxuser/moren_adds', { userid: uid, id: id }, function (res) {
      http.req('/Wxuser/addslist', { userid: uid }, function (res) {
        if (res.code == '0') {
          that.setData({
            addrlist: res.data
          })
        }
      });
    });


  },
  
  dianji: function (e) {
    var that = this
    var index = e.currentTarget.dataset.index
    var id = e.currentTarget.dataset.id


    wx.setStorageSync('adds', that.data.addrlist[index])
    if (that.data.tjorder == '1') {
      wx.navigateBack({
        delta: 1
      })
    } else {
      wx.navigateBack({
        delta: 1
      })

    }
  },
  onShow: function () {
    var that = this
    http.req('/Wxuser/addslist', { userid: wx.getStorageSync('user').userid }, function (res) {
      if (res.code == '0') {

        that.setData({
          addrlist: res.data
        })
      }
    });
  },
})